package xju_3_4.entity;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component("stu")
public class Student {
    @Value("Java")
    private String msg;

    public Student() {
        System.out.println("student constructor 创建了");
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    // 自定义
    public void study() {
        System.out.println("student study" + msg);
    }

    // 初始化完成方法
    @PostConstruct
    public void init() {
        System.out.println("student init");
    }
    // 销毁之前调用
    @PreDestroy
    public void destroy() {
        System.out.println("student destroy");
    }

    @Override
    public String toString() {
        return "Student{" +
                "msg='" + msg + '\'' +
                '}';
    }
}
